package com.atguigu.flink.datastreamapi.dirstribute;

import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * Created by Smexy on 2023/4/3
 *
 *  设置并行度：
 *      ①在全局配置中
 *              parallelism.default: 1
 *      ②提交job时
 *              flink run -p,--parallelism  x
 *      ③设置全局并行度
 *              env.setParallelism(1);
 *      ④设置某个算子的并行度
 *              算子..setParallelism(x);
 *
 *
 *      都设置了，优先级  ④ > ③ > ② > ①
 *
 *      并行度： 算子并行运算的程度。
 *
 */
public class Demo4_Parilisim
{
    public static void main(String[] args) {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        env.setParallelism(1);

        SingleOutputStreamOperator<String> ds = env.socketTextStream("hadoop102", 8888).name("source");

        ds.print().setParallelism(5);



        try {
            env.execute();
        } catch (Exception e) {
            e.printStackTrace();
        }


    }
}
